//
//  HBQsmContentTableView.m
//  HelloBeeQuick
//
//  Created by 李建强 on 16/8/20.
//  Copyright © 2016年 LiYiLin. All rights reserved.
//

#import "HBQsmContentTableView.h"

#import "HBQsmContentCell.h"

#import "HBQsmHeadView.h"

@interface HBQsmContentTableView()<UITableViewDataSource,UITableViewDelegate>

@property (nonatomic,strong) HBQsmHeadView*headView;

@end



@implementation HBQsmContentTableView

-(instancetype)initWithFrame:(CGRect)frame style:(UITableViewStyle)style{
    
    if (self = [super initWithFrame:frame style:style]) {
        [self setupUI];
        
        
        [self registerClass:[HBQsmContentCell class] forCellReuseIdentifier:@"contentCell"];
        
        [self registerClass:[HBQsmHeadView class] forHeaderFooterViewReuseIdentifier:@"head"];
    }
    
    return self;
    
}

-(void)setDataArray:(NSArray *)dataArray{
    
    _dataArray = dataArray;
    self.dataSource =self;
    self.delegate = self;

    [self reloadData];
}


-(void)setListArray:(NSArray<HBQsmListModel *> *)listArray{
    
    _listArray = listArray;
    
    [self reloadData];
    
}

#pragma mark
#pragma mark - 设置UI

-(void)setupUI{
    //设置颜色
    self.backgroundColor = [UIColor whiteColor];
    
    //添加控件
    
    
    

    
    
}

#pragma mark
#pragma mark - -------------数据源代理-----------------

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{

    return self.dataArray.count;
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataArray[section].count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    HBQsmContentCell *cell = [tableView dequeueReusableCellWithIdentifier:@"contentCell" forIndexPath:indexPath];
    cell.model = self.dataArray[indexPath.section][indexPath.row];
    
    
    
    return cell;
}






-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{

    return 15;
}

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    HBQsmHeadView *headView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:@"head"];
    
    headView.model = self.listArray[section];
    
    NSLog(@"%@",headView.model);
    
    
    return headView;
}

//- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
//    return @"si";
//}





@end




